package org.uiot.process

import groovy.transform.CompileStatic
import org.apache.flink.api.common.functions.FlatMapFunction
import org.apache.flink.util.Collector

@CompileStatic
class Encoding extends Codec implements FlatMapFunction<UnencodedPacket, EncodedPacket> {

    Encoding() {
        super()
    }

    @Override
    void flatMap(UnencodedPacket input, Collector<EncodedPacket> output) throws Exception {
        output.collect(
                new EncodedPacket(
                        input.f0, input.f1, input.f2, input.f3, encode(input.f1, input.f4)
                )
        )
    }
}
